package com.sctu.edu.tracks.utils;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import com.sctu.edu.tracks.MainActivity;
import com.sctu.edu.tracks.config.CacheConfig;
import com.sctu.edu.tracks.utils.httputils.SharePreference;

public class JumpUtils {
    private static SharePreference sharePreference;

    /**
     * 跳转
     *
     * @param thisContents
     * @param newClass
     */
    public static void jumpActivity(Context thisContents, Class newClass) {
        Intent intent = new Intent(thisContents, newClass);
        thisContents.startActivity(intent);
    }

    public static void jumpActivity(Context thisContents, Class newClass, Bundle bundle) {
        Intent intent = new Intent(thisContents, newClass);
        intent.putExtras(bundle);
        thisContents.startActivity(intent);
    }


    public static boolean isLogin(Context thisContents){

        sharePreference = SharePreference.getInstance(thisContents);

        if (!sharePreference.ifHaveShare(CacheConfig.CACHE_TOKEN)){

            return false;
        }
        return true;
    }

    public static void activityToFragmentJump(Context thisContents,Bundle bundle ){

        jumpActivity(thisContents, MainActivity.class,bundle);

    }
}
